package shape;

/**
 * @author Zach Turk
 */

import javax.media.opengl.*;

import main.SceneGraphNode;

public class Ellipse extends SceneGraphNode implements Shape {
	
	public Ellipse() {
		super(true);
	}
	
	public Ellipse(boolean pickable) {
		super(pickable);
	}
	
	public void renderGeometry(GLAutoDrawable drawable) {
		GL2 gl = drawable.getGL().getGL2();
		gl.glBegin(GL.GL_TRIANGLE_FAN);
		
		gl.glVertex2f(0, 0);
		
		//the denominator in Math.PI/30 is the number of sides the circle will have
		//for some reason, this number needs to be a multiple of 3 to get a full circle
		double step = 2*Math.PI/30;
		for (float i = 0; i < 2*Math.PI; i += step) {
			gl.glVertex2d(Math.cos(i), Math.sin(i));
		}
		gl.glEnd();
	}
}
